import re
import requests


url = "https://www.hao123.com/"
ua = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"}

rq = requests.get(url, headers=ua)

title_pattern = r"(?<=<title).*?(?=</title>)"

title_search = re.search(title_pattern, rq.text)

title = title_search.group()
print("网站的标题是: ", title)

